/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GUI;

import Model.Gates.Gate;
import Model.Gates.Inverter;
import Model.Main.Wire;
import java.awt.Dimension;
import java.awt.Point;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;

/**
 *
 * @author bg
 */
public class InverterView extends AbstractElementView  {
    Inverter inverter;

    public InverterView(Inverter inverter, Point position) {
        inputs = new ArrayList<Point>();
        outputs = new ArrayList<Point>();
        try {
            img = ImageIO.read(getClass().getResource("Images/not.png"));
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Nincsen " +this.getClass().getName()+ " kép!");
        }
        state = false;
        this.inverter = inverter;
        this.position = position;
        this.preferredImageSize = new Dimension(30, 64);

        for (int i = Math.round(64 / 2); i < 60; i += Math.round(64 / 2)) {
            inputs.add(new Point(position.x,position.y+i));
        }
        for (int i = Math.round(64 / (inverter.getMaxOutput() + 1)); i < 60; i += Math.round(64 / (inverter.getMaxOutput() + 1))) {
            outputs.add(new Point(position.x + 30, position.y + i));
        }
    }
    @Override
    void setOutputWireModel(Wire w, int inputNumber) {

        inverter.setOutputWire(w, inputNumber);
    }

    @Override
    Gate getGate() {
        return inverter;
    }
}
